package com.xkdx.caipiao.presistence.costlist;
import java.util.ArrayList;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;

public class CostListModule extends AbsModule {
	public ArrayList<CostListInfo> list;

	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			list = new ArrayList<CostListInfo>();
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("GetProList")) {
					parseCost(jsonObj.getJSONArray("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private void parseCost(JSONArray jsonArray) throws Exception {
		try {

			JSONArray array = jsonArray;
			for (int i = 0; i < array.size(); i++) {
				JSONObject obj = array.getJSONObject(i);
				CostListInfo costinfo = new CostListInfo();
				costinfo.setId(obj.getString("id"));
				costinfo.setTitle(obj.getString("title"));
				costinfo.setValue(obj.getString("value"));
				list.add(costinfo);
			}

		} catch (Exception e) {

			throw e;
		}
	}
}
